package com.lagou.boot;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lagou.client.RPCConsumer;
import com.lagou.pojo.RpcRequest;
import com.lagou.service.IUserService;

public class ConsumerBoot {

    //参数定义
    private static final String PROVIDER_NAME = "UserService#sayHello#";

    public static void main(String[] args) throws InterruptedException {
        RpcRequest rpcRequest=new RpcRequest();
        rpcRequest.setClassName("com.lagou.service.IUserService");
        rpcRequest.setMethodName("rpcRequestService");
        rpcRequest.setParameters(new Object[]{"hello 我要使用Json格式跟服务端你交互，可以吗？"});
        rpcRequest.setParameterTypes(new Class[]{String.class});
        rpcRequest.setRequestId("userService#rpcRequestService");


        //1.创建代理对象
        IUserService service = (IUserService) RPCConsumer.createProxy(IUserService.class,  rpcRequest);

        //2.循环给服务器写数据
        while (true){
            String result = service.sayHello("are you ok !!");
            System.out.println(result);
            Thread.sleep(2000);
        }
    }
}
